package com.heima.utils.thread;

import com.heima.model.user.pojos.ApUser;
import org.springframework.stereotype.Component;

/**
 * <p>
 *
 * </p>
 *
 * @author lzt
 * @version 1.0
 * @since 2024/4/9 上午11:10
 */

public class AppThreadLocalUtil {
    private static ThreadLocal<ApUser> WM_USER_THREAD_LOCAL = new ThreadLocal<>();

    // 存入线程
    public static void setUser(ApUser apUser) {
        WM_USER_THREAD_LOCAL.set(apUser);
    }

    // 获取线程
    public static ApUser getUser() {
        return WM_USER_THREAD_LOCAL.get();
    }

    // 销毁
    public static void clear() {
        WM_USER_THREAD_LOCAL.remove();
    }
}
